﻿using System;
using System.Collections;//非泛型集合的命名空间
using System.Collections.Generic;//泛型集合的命名空间
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A58非泛型集合
{
    class Program
    {
        static void Main1(string[] args)
        {
            ArrayList ls = new ArrayList();  //等同于List<Object>
            ls.Add("张三");
            ls.Add(123);
            ls.Add(true);

            string name = ls[0] as string ;
            int n = (int)ls[1];

            Hashtable tab = new Hashtable();
            tab.Add("主机","192,168.0.254");
            string ip = tab["主机"] as string;
        }

        static void Main(string[] args)
        {
            Student s1 = new Student(3,"张三");
            s1.SayAge();
            Student s2 = new Student(4,"李四");
            s2.SayAge();
            s2.SayName();
        }
    }

    #region 补充:扩展方法
    class Student
    {
        public int age;
        public string name;

        public Student(int age,string name)
        {
            this.age = age;
            this.name = name;
        }

        public void SayAge() 
        {
            Console.WriteLine(this.age);
        }
    }


    //扩展方法
    static class StudentExtent
    {
        public static void SayName(this Student student)  //给Student对象增加了一个SayName的方法
        {
            Console.WriteLine(student.name);
        }
    }
    #endregion


}
